package com.sinosoft.builder.model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 
 * @author 潘巍（Peter Pan）
 * @since 2010-5-14 下午05:16:47
 */
public class JavaMethod extends JavaLanguageElement {
	
	private Class<?> returnType;
	
	private MethodBody methodBody;
	
	private List <Argument> arguments = new ArrayList<Argument>();
	private List<Class<Throwable>> exceptions = new ArrayList<Class<Throwable>>();
	
	public List<Class<Throwable>> getExceptions() {
		return exceptions;
	}

	public void setExceptions(List<Class<Throwable>> exceptions) {
		this.exceptions = exceptions;
	}

	public JavaMethod(String name) {
		super(name);
		this.returnType = Void.TYPE;
	}

	public JavaMethod(String name, Argument ... arguments) {
		this(name);
		this.arguments = Arrays.asList(arguments);
	}

	public JavaMethod(String name, Class<?> returnType, Argument ... arguments) {
		this(name);
		this.returnType = returnType;
		this.arguments = Arrays.asList(arguments);
	}
	public List<Argument> getArguments() {
		return arguments;
	}
	
	public MethodBody getMethodBody() {
		return methodBody;
	}


	public Class<?> getReturnType() {
		return returnType;
	}

	public void setMethodBody(MethodBody methodBody) {
		this.methodBody = methodBody;
		if (methodBody != null) {
			methodBody.setMethod(this);
		}
	}
}
